home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / games / nhak_src.zip / FOUNTAIN.C < prev    next >
C/C++ Source or Header  |  1993-03-16  |  11KB  |  443 lines

  1. /*    SCCS Id: @(#)fountain.c    3.0    88/12/22
  2. /* Code for drinking from fountains.   */
  3. /* Scott R. Turner, srt@ucla, 10/27/86 */
  4. /* NetHack may be freely redistributed.  See license for details. */
  5.  
  6. #include "hack.h"
  7.  
  8. #ifdef FOUNTAINS
  9. static void NDECL(dowatersnakes);
  10. static void NDECL(dowaterdemon);
  11. static void NDECL(dowaternymph);
  12. static void FDECL(dogushforth,(int));    
  13. static void NDECL(dofindgem);
  14.  
  15. static
  16. void
  17. dowatersnakes() /* Fountain of snakes! */ {
  18.     register int num = rnd(6);
  19.     if (!(mons[PM_WATER_MOCCASIN].geno & G_GENOD)) {
  20.         if (!Blind)
  21.             pline("An endless stream of %s pours forth!",
  22.                 Hallucination ? makeplural(rndmonnam())
  23.                 : "snakes");
  24.         else
  25.             You("hear something hissing!");
  26.         while(num-- > 0) (void) makemon(&mons[PM_WATER_MOCCASIN],u.ux,u.uy);
  27.     } else
  28.         pline("The fountain bubbles furiously for a moment, then calms.");
  29. }
  30.  
  31. static
  32. void
  33. dowaterdemon() /* Water demon */ {
  34. register struct monst *mtmp;
  35.  
  36.     if((mtmp = makemon(&mons[PM_WATER_DEMON],u.ux,u.uy))) {
  37.         if (!Blind)
  38.             You("have unleashed %s!", defmonnam(mtmp));
  39.         else
  40.         You("feel the presence of evil.");
  41.  
  42.     /* Give those on low levels a (slightly) better chance of survival */
  43.         if ( rnd(100) > (80 + dlevel)) {
  44.         pline("Grateful for %s release, %s grants you a wish!",
  45.             Blind ? "its" : "his", Blind ? "it" : "he" );
  46.         makewish();
  47.         mongone(mtmp);
  48.         }
  49.     }
  50. }
  51.  
  52. static
  53. void
  54. dowaternymph() /* Water Nymph */ {
  55.     register struct monst *mtmp;
  56.     if((mtmp = makemon(&mons[PM_WATER_NYMPH],u.ux,u.uy))) {
  57.         if (!Blind)
  58.            You("have attracted %s!", defmonnam(mtmp));
  59.         else
  60.            You("hear a seductive voice.");
  61.         mtmp->msleep = 0;
  62.     } else
  63.         if (!Blind)
  64.            pline("A large bubble rises to the surface and pops.");
  65.         else
  66.            You("hear a loud pop.");
  67. }
  68.  
  69.  
  70. static
  71. void
  72. dogushforth(drinking) /* Gushing forth in this room */
  73. int drinking;
  74. {
  75. register int num = rnd(10);
  76. register xchar mx,my;
  77. register int tryct = 0;
  78. register int uroom = inroom(u.ux, u.uy);
  79. register struct mkroom *croom = &rooms[uroom];
  80. register int madepool = 0;
  81.  
  82.     if(croom->hx < 0 || has_upstairs(croom) ||
  83.        has_dnstairs(croom))  {
  84.         if (drinking) Your("thirst is quenched.");
  85.         else pline("Water sprays all over you.");
  86.         return;
  87.     }
  88.     while(num--) {
  89.         do {
  90.         if(++tryct > 200)  {
  91.             if(madepool)
  92.             pline("Water gushes forth from the overflowing fountain!");
  93.             else if (drinking) Your("thirst is quenched.");
  94.         else pline("Water sprays all over you.");
  95.             return;
  96.         }
  97.         mx = somex(croom);
  98.         my = somey(croom);
  99.         } while(nexttodoor(mx,my) || !((mx+my)%2) ||
  100.             (mx == u.ux && my == u.uy) ||
  101.             (IS_POOL(levl[mx][my].typ)));
  102.                
  103.         /* Put a pool at mx, my */
  104.              
  105.         levl[mx][my].typ = POOL;
  106.         levl[mx][my].doormask = 0;
  107.         mnewsym(mx,my);
  108.         if (cansee(mx, my))
  109.         prl(mx, my);
  110.         madepool = 1;
  111.     }
  112.  
  113.     pline("Water gushes forth from the overflowing fountain!");
  114. }
  115.  
  116. static
  117. void
  118. dofindgem() /* Find a gem in the sparkling waters. */ {
  119.  
  120.     if (!Blind) You("spot a gem in the sparkling waters!");
  121.     (void) mksobj_at(rnd_class(DILITHIUM_CRYSTAL, LUCKSTONE-1), u.ux, u.uy);
  122.     levl[u.ux][u.uy].looted = T_LOOTED;
  123. }
  124.  
  125. void
  126. dryup(){
  127.     if (!rn2(3) && IS_FOUNTAIN(levl[u.ux][u.uy].typ)) {
  128.         if (!Blind) pline("The fountain dries up!");
  129.         levl[u.ux][u.uy].typ = ROOM;
  130.         levl[u.ux][u.uy].looted = 0;
  131.         if(Invisible) newsym(u.ux, u.uy);
  132.         fountsound--;
  133.     }
  134. }
  135.  
  136. void
  137. drinkfountain() {
  138.  
  139.     /* What happens when you drink from a fountain? */
  140.     register int fate = rnd(30);
  141.  
  142.     if(Levitation)    {
  143.         You("are floating high above the fountain.");
  144.         return;
  145.     }
  146.     else if (fate < 10) {
  147.         pline("The cool draught refreshes you.");
  148.         u.uhunger += rnd(10); /* don't choke on water */
  149.     } else {
  150.         switch (fate) {
  151.  
  152.         case 19: /* Self-knowledge */
  153.  
  154.             You("feel self-knowledgeable...");
  155.             more();
  156.             enlightenment();
  157.             pline("The feeling subsides.");
  158.             break;
  159.  
  160.         case 20: /* Foul water */
  161.  
  162.             pline("The water is foul!  You gag and vomit.");
  163.             morehungry(rnd(20)+10);
  164.             vomit();
  165.             break;
  166.  
  167.         case 21: /* Poisonous */
  168.  
  169.             pline("The water is contaminated!");
  170.             if (Poison_resistance) {
  171. #ifdef TUTTI_FRUTTI
  172.        pline("Perhaps it is runoff from the nearby %s farm.", pl_fruit);
  173. #else
  174.        pline("Perhaps it is runoff from the nearby orange farm.");
  175. #endif
  176.                losehp(rnd(4),"unrefrigerated sip of juice",
  177.                 KILLED_BY_AN);
  178.                break;
  179.             }
  180.             losestr(rn1(4,3));
  181.             losehp(rnd(10),"contaminated water", KILLED_BY);
  182.             break;
  183.     
  184.         case 22: /* Fountain of snakes! */
  185.  
  186.             dowatersnakes();
  187.             break;
  188.  
  189.         case 23: /* Water demon */
  190.             dowaterdemon();
  191.             break;
  192.  
  193.         case 24: /* Curse an item... */ {
  194.             register struct obj *obj;
  195.  
  196.             pline("This water's no good!");
  197.             morehungry(rnd(20)+10);
  198.             for(obj = invent; obj ; obj = obj->nobj)
  199.                 if (!rn2(5))    curse(obj);
  200.             break;
  201.             }
  202.              
  203.         case 25: /* See invisible */
  204.  
  205.             You("see an image of someone stalking you.");
  206.             pline("But it disappears.");
  207.             HSee_invisible |= INTRINSIC;
  208.             break;
  209.  
  210.         case 26: /* See Monsters */
  211.  
  212.             (void) monster_detect((struct obj *)0);
  213.             break;
  214.  
  215.         case 27: /* Find a gem in the sparkling waters. */
  216.  
  217.             if (!levl[u.ux][u.uy].looted) {
  218.                 dofindgem();
  219.                 break;
  220.             }
  221.  
  222.         case 28: /* Water Nymph */
  223.  
  224.             dowaternymph();
  225.             break;
  226.  
  227.         case 29: /* Scare */ {
  228.             register struct monst *mtmp;
  229.  
  230.             pline("This water gives you bad breath!");
  231.             for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) 
  232.                 mtmp->mflee = 1;
  233.             }
  234.             break;
  235.  
  236.         case 30: /* Gushing forth in this room */
  237.  
  238.             dogushforth(TRUE);
  239.             break;
  240.  
  241.         default:
  242.  
  243.             pline("This tepid water is tasteless.");
  244.             break;
  245.         }
  246.     }
  247.     dryup();
  248. }
  249.  
  250. void
  251. dipfountain(obj)
  252. register struct obj *obj;
  253. {
  254.     if (Levitation) {
  255.         You("are floating high above the fountain.");
  256.         return;
  257.     }
  258.  
  259.     if (obj->otyp == LONG_SWORD && u.ulevel >= 5 && !rn2(6)
  260. #ifdef NAMED_ITEMS
  261.         && !is_artifact(obj) && !exist_artifact(obj, "Excalibur")
  262. #else
  263.         && !strcmp(ONAME(obj), "Excalibur")
  264. #endif
  265.        ) {
  266.         /* The lady of the lake acts! - Eric Backus */
  267.         /* Be *REAL* nice */
  268.     pline("A murky hand from the depths reaches up to bless the sword.");
  269.     pline("As the hand retreats, the fountain disappears!");
  270.  
  271. #ifndef NAMED_ITEMS
  272.         if(obj->spe < 5) obj->spe = 5;
  273. #else
  274.         /* otherwise +rnd(10) / +5 "Super"sword */
  275.         obj = oname(obj, "Excalibur", 1);
  276. #endif
  277.         bless(obj);
  278.         obj->rustfree = 1;
  279.         levl[u.ux][u.uy].typ = ROOM;
  280.                 levl[u.ux][u.uy].looted = 0;
  281.         if(Invisible) newsym(u.ux, u.uy);
  282.         fountsound--;
  283.         return;
  284.     } else (void) get_wet(obj);
  285.  
  286.     switch (rnd(30)) {
  287.         case 16: /* Curse the item */
  288.             curse(obj);
  289.             break;
  290.         case 17:
  291.         case 18:
  292.         case 19:
  293.         case 20: /* Uncurse the item */
  294.             if(obj->cursed) {
  295.                 if (!Blind)
  296.                 pline("The water glows for a moment.");
  297.                 obj->cursed = 0;
  298.             } else {
  299.                 pline("A feeling of loss comes over you.");
  300.             }
  301.             break;
  302.         case 21: /* Water Demon */
  303.             dowaterdemon();
  304.             break;
  305.         case 22: /* Water Nymph */
  306.             dowaternymph();
  307.             break;
  308.         case 23: /* an Endless Stream of Snakes */
  309.             dowatersnakes();
  310.             break;
  311.         case 24: /* Find a gem */
  312.             dofindgem();
  313.             break;
  314.         case 25: /* Water gushes forth */
  315.             dogushforth(FALSE);
  316.             break;
  317.         case 26: /* Strange feeling */
  318.             pline("A strange tingling runs up your %s.",
  319.                             body_part(ARM));
  320.             break;
  321.         case 27: /* Strange feeling */
  322.             You("feel a sudden chill.");
  323.             break;
  324.         case 28: /* Strange feeling */
  325.             pline("An urge to take a bath overwhelms you.");
  326.             if (u.ugold > 10) {
  327.                 u.ugold -= somegold() / 10;
  328.                 You("lost some of your gold in the fountain!");
  329.                 levl[u.ux][u.uy].looted = 0;
  330.             }
  331.             break;
  332.         case 29: /* You see coins */
  333.  
  334.         /* We make fountains have more coins the closer you are to the
  335.          * surface.  After all, there will have been more people going
  336.          * by.    Just like a shopping mall!  Chris Woodbury  */
  337.  
  338.             mkgold((long)(rnd((MAXLEVEL-dlevel)*2)+5), u.ux, u.uy);
  339.             if (!Blind)
  340.         pline("Far below you, you see coins glistening in the water.");
  341.             break;
  342.     }
  343.     dryup();
  344.     return;
  345. }
  346. #endif
  347.  
  348. #ifdef SINKS
  349. void
  350. drinksink()
  351. {
  352.     if (Levitation) {
  353.         You("are floating high above the sink.");
  354.         return;
  355.     }
  356.     switch(rn2(20)) {
  357.         static struct obj NEARDATA *otmp;
  358.         case 0: You("take a sip of very cold water.");
  359.             break;
  360.         case 1: You("take a sip of very warm water.");
  361.             break;
  362.         case 2: You("take a sip of scalding hot water.");
  363.             if (Fire_resistance)
  364.                 pline("It seems quite tasty.");
  365.             else losehp(rnd(6), "sipping boiling water", KILLED_BY);
  366.             break;
  367.         case 3: if (mons[PM_SEWER_RAT].geno & G_GENOD)
  368.                 pline("The sink seems quite dirty.");
  369.             else {
  370.                 static struct monst NEARDATA *mtmp;
  371.  
  372.                 mtmp = makemon(&mons[PM_SEWER_RAT], u.ux, u.uy);
  373.                 pline("Eek!  There's %s in the sink!",
  374.                     Blind ? "something squirmy" :
  375.                     defmonnam(mtmp));
  376.             }
  377.             break;
  378.         case 4: do {
  379.                 otmp = mkobj(POTION_SYM,FALSE);
  380.             } while(otmp->otyp == POT_WATER);
  381.             otmp->cursed = otmp->blessed = 0;
  382.             if (Blind)
  383.                 pline("The sink emits some odd liquid.");
  384.             else
  385.                 pline("The sink emits a stream of %s water.",
  386.                     Hallucination ? hcolor() :
  387.                     objects[otmp->otyp].oc_descr);
  388.             otmp->dknown = !(Blind || Hallucination);
  389.             otmp->quan++; /* Avoid panic upon useup() */
  390.             otmp->corpsenm = 1; /* kludge for docall() */
  391.             (void) dopotion(otmp);
  392.             obfree(otmp, (struct obj *)0);
  393.             break;
  394.         case 5: if (!levl[u.ux][u.uy].looted) {
  395.                 You("find a ring in the sink!");
  396.                 (void) mkobj_at(RING_SYM, u.ux, u.uy, TRUE);
  397.                 levl[u.ux][u.uy].looted = T_LOOTED;
  398.             } else pline("Some dirty water backs up in the drain.");
  399.             break;
  400.         case 6: pline("The pipes break!  Water spurts out!");
  401.             sinksound--;
  402.             levl[u.ux][u.uy].doormask = 0;
  403. #ifdef FOUNTAINS
  404.             levl[u.ux][u.uy].typ = FOUNTAIN;
  405.             fountsound++;
  406. #else
  407.             levl[u.ux][u.uy].typ = ROOM;
  408. #endif
  409.             if (Invisible) newsym(u.ux,u.uy);
  410.             break;
  411.         case 7: pline("The water moves as though of its own will!");
  412.             if (!makemon(&mons[PM_WATER_ELEMENTAL], u.ux, u.uy))
  413.                 pline("But it quiets down.");
  414.             break;
  415.         case 8: pline("Yuk, this water tastes awful.");
  416.             more_experienced(1,0);
  417.             newexplevel();
  418.             break;
  419.         case 9: pline("Gaggg... this tastes like sewage!  You vomit.");
  420.             morehungry(rnd(30-ACURR(A_CON))+10);
  421.             vomit();
  422.             break;
  423. #ifdef POLYSELF
  424.         case 10: pline("This water contains toxic wastes!");
  425.             You("undergo a freakish metamorphosis!");
  426.             polyself();
  427.             break;
  428. #endif
  429.         /* more odd messages --JJB */
  430.         case 11: You("hear clanking from the pipes....");
  431.             break;
  432.         case 12: You("hear snatches of song from among the sewers...");
  433.             break;
  434.         case 19: if (Hallucination) {
  435.                 pline("A murky hand reaches up out of the drain... --oops--");
  436.                 break;
  437.             }
  438.         default: You("take a sip of %s water.",
  439.             rn2(3) ? (rn2(2) ? "cold" : "warm") : "hot");
  440.     }
  441. }
  442. #endif /* SINKS /**/
  443.